package com.zh.note.controller;


import com.zh.note.entity.UserEntity;
import com.zh.note.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户 前端控制器
 * </p>
 *
 * @author zhanghuan
 * @since 2024-09-07
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;


    @PostMapping(value = "/user/add")
    public int addUser(@RequestBody UserEntity userEntity, HttpServletRequest request) {
        return userService.addUser(userEntity);
    }

    @GetMapping(value = "/user/{id}")
    public UserEntity getUserById(@PathVariable Integer id) {
        return userService.getUserById(id);
    }
}
